package dkbta.ontology.values;

import dkbta.ontology.loading.OntologyException;
import dkbta.util.Utils;

/**
 * A numeric range with a scale
 * 
 * @author Uri Kanonov
 */
public class ScaledNumericValues implements ScaledValues{
	/**
	 * An enum listing the possible scales for numeric values
	 * 
	 * @author Uri Kanonov
	 */
	public static enum Scale{
		INTERVAL, RATIO, ORDINAL
	}

	/** The scale of the values */
	private final Scale _scale;

	/** The units in which the values are measured */
	private final String _unit;

	/** The numeric values */
	private final NumericValues _values;

	/**
	 * Constructs a ScaledNumericValues object with the given parameters
	 * 
	 * @param scale The scale of the numeric values
	 * @param minE The lower bound with equality
	 * @param min The lower bound without equality
	 * @param maxE The upper bound with equality
	 * @param max The upper bound without equality
	 * @param unit The unit in which the values are measured
	 * @throws OntologyException If the scale is invalid
	 */
	public ScaledNumericValues(String scale, NumericValues values, String unit)
			throws OntologyException{
		try{
			_scale = Utils.enumForName(Scale.class, scale);
		}catch(IllegalArgumentException e){
			throw new OntologyException(e);
		}

		_values = values;
		_unit = unit;
	}

	public ValuesType getValueType(){
		return ValuesType.NUMERIC;
	}

	/**
	 * Returns the scale in use
	 * 
	 * @return The scale in use
	 */
	public Scale getScale(){
		return _scale;
	}

	public NumericValues getValues(){
		return _values;
	}

	@Override
	public String toString(){
		return "Scale: " + _scale + ", Unit: " + _unit + ", " + _values;
	}
}
